home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / RCS / exit.c,v < prev    next >
Encoding:
Text File  |  1992-03-27  |  5.2 KB  |  273 lines

  1. head     1.9;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.8.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.9
  10. date     92.03.27.13.41.59;  author rab;  state Exp;
  11. branches ;
  12. next     1.8;
  13.  
  14. 1.8
  15. date     90.09.22.20.32.46;  author rab;  state Exp;
  16. branches 1.8.1.1;
  17. next     1.7;
  18.  
  19. 1.7
  20. date     89.03.22.00.47.04;  author rab;  state Exp;
  21. branches ;
  22. next     1.6;
  23.  
  24. 1.6
  25. date     88.11.28.09.26.09;  author rab;  state Exp;
  26. branches ;
  27. next     1.5;
  28.  
  29. 1.5
  30. date     88.07.25.11.10.58;  author ouster;  state Exp;
  31. branches ;
  32. next     1.4;
  33.  
  34. 1.4
  35. date     88.07.25.10.59.59;  author ouster;  state Exp;
  36. branches ;
  37. next     1.3;
  38.  
  39. 1.3
  40. date     88.07.14.09.46.48;  author ouster;  state Exp;
  41. branches ;
  42. next     1.2;
  43.  
  44. 1.2
  45. date     88.06.17.18.10.47;  author ouster;  state Exp;
  46. branches ;
  47. next     1.1;
  48.  
  49. 1.1
  50. date     88.05.21.14.46.06;  author ouster;  state Exp;
  51. branches ;
  52. next     ;
  53.  
  54. 1.8.1.1
  55. date     91.10.01.19.49.43;  author kupfer;  state Exp;
  56. branches ;
  57. next     ;
  58.  
  59.  
  60. desc
  61. @@
  62.  
  63.  
  64. 1.9
  65. log
  66. @Added on_exit, and had to change atexit.c and exit.c to make local variables global.
  67. @
  68. text
  69. @/* 
  70.  * exit.c --
  71.  *
  72.  *    This file contains the source code for the "exit" library
  73.  *    procedure.
  74.  *
  75.  * Copyright 1988 Regents of the University of California
  76.  * Permission to use, copy, modify, and distribute this
  77.  * software and its documentation for any purpose and without
  78.  * fee is hereby granted, provided that the above copyright
  79.  * notice appear in all copies.  The University of California
  80.  * makes no representations about the suitability of this
  81.  * software for any purpose.  It is provided "as is" without
  82.  * express or implied warranty.
  83.  */
  84.  
  85. #ifndef lint
  86. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/exit.c,v 1.8 90/09/22 20:32:46 rab Exp Locker: rab $ SPRITE (Berkeley)";
  87. #endif not lint
  88.  
  89. #include <stdio.h>
  90. #include <stdlib.h>
  91. #include <sprite.h>
  92. #include <proc.h>
  93.  
  94. /*
  95.  * Variables shared with atexit.c, and on_exit.c:
  96.  */
  97.  
  98. void (*_exitHandlers[32])();        /* Function table. */
  99. int _exitNumHandlers = 0;        /* Number of functions currently
  100.                      * registered in table. */
  101. long _exitHandlerArgs[32];        /* Arguments to pass to functions. */
  102. int _exitTableSize = 32;        /* Number of entries in table. */
  103.  
  104. /*
  105.  *----------------------------------------------------------------------
  106.  *
  107.  * exit --
  108.  *
  109.  *    Terminate the process.
  110.  *
  111.  * Results:
  112.  *    Never returns.
  113.  *
  114.  * Side effects:
  115.  *    Any procedures registered by calls to "atexit" are invoked,
  116.  *    and any open I/O streams are flushed and closed.
  117.  *
  118.  *----------------------------------------------------------------------
  119.  */
  120.  
  121. int
  122. exit(status)
  123.     int status;            /* Status to return to parent process.  0 is
  124.                  * the normal value for "success". */
  125. {
  126.     while (_exitNumHandlers > 0) {
  127.     _exitNumHandlers -= 1;
  128.     (*_exitHandlers[_exitNumHandlers])(_exitHandlerArgs[_exitNumHandlers]);
  129.     }
  130.     _cleanup();
  131.     _exit(status);
  132. }
  133. @
  134.  
  135.  
  136. 1.8
  137. log
  138. @Changed exit() to call _exit() instead of Proc_RawExit().  Some programs
  139. define their own _exit instead of using atexit().  E.g. the decStation
  140. profiler.
  141. @
  142. text
  143. @d18 1
  144. a18 1
  145. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/exit.c,v 1.7 89/03/22 00:47:04 rab Exp Locker: rab $ SPRITE (Berkeley)";
  146. d27 1
  147. a27 1
  148.  * Variables shared from atexit.c:
  149. d30 2
  150. a31 2
  151. extern void (*_exitHandlers[])();    /* Function table. */
  152. extern int _exitNumHandlers;        /* Number of functions currently
  153. d33 2
  154. a34 1
  155. extern int _exitTableSize;        /* Number of entries in table. */
  156. d60 1
  157. a60 1
  158.     (*_exitHandlers[_exitNumHandlers])();
  159. @
  160.  
  161.  
  162. 1.8.1.1
  163. log
  164. @Initial branch for Sprite server.
  165. @
  166. text
  167. @d18 1
  168. a18 1
  169. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/exit.c,v 1.8 90/09/22 20:32:46 rab Exp $ SPRITE (Berkeley)";
  170. @
  171.  
  172.  
  173. 1.7
  174. log
  175. @*** empty log message ***
  176. @
  177. text
  178. @d18 1
  179. a18 1
  180. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/exit.c,v 1.6 88/11/28 09:26:09 rab Exp Locker: rab $ SPRITE (Berkeley)";
  181. d62 1
  182. a62 1
  183.     Proc_RawExit(status);
  184. @
  185.  
  186.  
  187. 1.6
  188. log
  189. @Changed return value to void.
  190. @
  191. text
  192. @d18 1
  193. a18 1
  194. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/exit.c,v 1.5 88/07/25 11:10:58 ouster Exp Locker: rab $ SPRITE (Berkeley)";
  195. d22 1
  196. d52 1
  197. a52 1
  198. void
  199. @
  200.  
  201.  
  202. 1.5
  203. log
  204. @Lint.
  205. @
  206. text
  207. @d18 1
  208. a18 1
  209. static char rcsid[] = "$Header: exit.c,v 1.4 88/07/25 10:59:59 ouster Exp $ SPRITE (Berkeley)";
  210. d51 1
  211. @
  212.  
  213.  
  214. 1.4
  215. log
  216. @Make exit have standard UNIX return value.
  217. @
  218. text
  219. @d18 1
  220. a18 1
  221. static char rcsid[] = "$Header: exit.c,v 1.3 88/07/14 09:46:48 ouster Exp $ SPRITE (Berkeley)";
  222. d21 1
  223. @
  224.  
  225.  
  226. 1.3
  227. log
  228. @Move variables from exit.c to atexit.c, so that atexit can be
  229. used along with a private exit (as in csh).
  230. @
  231. text
  232. @d18 1
  233. a18 1
  234. static char rcsid[] = "$Header: exit.c,v 1.2 88/06/17 18:10:47 ouster Exp $ SPRITE (Berkeley)";
  235. a49 1
  236. void
  237. @
  238.  
  239.  
  240. 1.2
  241. log
  242. @Call Proc_RawExit, not Proc_Exit.
  243. @
  244. text
  245. @d18 1
  246. a18 1
  247. static char rcsid[] = "$Header: exit.c,v 1.1 88/05/21 14:46:06 ouster Exp $ SPRITE (Berkeley)";
  248. d25 1
  249. a25 1
  250.  * Variables (shared with atexit.c):
  251. d28 2
  252. a29 2
  253. void (*_exitHandlers[32])();        /* Function table. */
  254. int _exitNumHandlers = 0;        /* Number of functions currently
  255. d31 1
  256. a31 1
  257. int _exitTableSize = 32;        /* Number of entries in table. */
  258. @
  259.  
  260.  
  261. 1.1
  262. log
  263. @Initial revision
  264. @
  265. text
  266. @d18 1
  267. a18 1
  268. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  269. d60 1
  270. a60 1
  271.     Proc_Exit(status);
  272. @
  273.